﻿// Copyright 2008 (c) Michael Reichenauer, SWEDEN. All rights reserved.
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSMock.Implementation;

namespace PSMock
{

	/// <summary>
	/// Base class for FunctionOption and MethodOption.
	/// </summary>
	public class Option
	{
		protected MockedFunction mockedFunction;

		/// <summary>
		/// Initializes a new instance of the <see cref="Option"/> class.
		/// </summary>
		/// <param name="mockedFunction">The mocked function.</param>
		public Option(MockedFunction mockedFunction)
		{
			this.mockedFunction = mockedFunction;
		}


		/// <summary>
		/// Mock this function or method for all instances.
		/// </summary>
		public Option ForAllInstances()
		{
			mockedFunction.Instance = null;
			return this;
		}


		/// <summary>
		/// Throws the specified exception when the mocked method of function is called.
		/// </summary>
		public Option Throw(Exception exception)
		{
			mockedFunction.ThrowException = exception;
			return this;
		}
	}
}
